package ioc16;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SomeBean implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, InitializingBean, DisposableBean {

    private String str;

    public SomeBean() {
        System.out.println("1.实例化\tSomeBean.SomeBean()");
    }

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        System.out.println("2.DI\tSomeBean.setStr()");
        this.str = str;
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3.BeanNameAware的setBeanName方法\tSomeBean.setBeanName()");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("4.BeanFactoryAware的setBeanFactory方法\tSomeBean.setBeanFactory()");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("5.ApplicationContextAware的setApplicationContext方法\tSomeBean.setApplicationContext()");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("7.afterPropertiesSet方法\tSomeBean.afterPropertiesSet()");
    }

    public void myInit(){
        System.out.println("8.初始化方法\tSomeBean.myInit()");
    }

    public void doSome(){
        System.out.println("10.使用\tSomeBean.doSome()");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("11.destroy方法\tSomeBean.destroy()");
    }

    public void myDestroy(){
        System.out.println("12.销毁方法\tSomeBean.myDestroy()");
    }
}
